package com.bcu.team.comment.service.serviceImpl;

import com.bcu.team.comment.entity.Message;
import com.bcu.team.comment.entity.Picture;
import com.bcu.team.comment.mapper.PictureMapper;
import com.bcu.team.comment.service.PictureService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class PictureServiceImpl implements PictureService {

    @Resource
    private PictureMapper pictureMapper;

    @Override
    public Message queryPicture(Integer pictureId) {
        return Message.success(null).add(pictureMapper.selectByPrimaryKey(pictureId));
    }

    @Override
    public Message addPicture(Picture picture) {
        return pictureMapper.insertSelective(picture) > 0 ? Message.success(null) : Message.fail(null);
    }

    @Override
    public Message delPicture(Integer pictureId) {
        return pictureMapper.deleteByPrimaryKey(pictureId) > 0 ? Message.success(null) : Message.fail(null);
    }

    @Override
    public Message updatePicture(Picture picture) {
        return pictureMapper.updateByPrimaryKeySelective(picture) > 0 ? Message.success(null) : Message.fail(null);
    }
}
